package com.lkm.app_ui.m.Imple.system_camera;

import android.util.Log;

import com.lkm.app_ui.AppConst;
import com.lkm.app_ui.m.camera.CameraModule;
import com.lkm.javatool.lang.RunnablePR;



public class SystemCameraModuleImple implements CameraModule {

    private static final String TAG = "slient_tack_pic";


    private SlientCamera slientCamera;

    @Override
    public synchronized boolean open() {
        Log.i(TAG, "SlientTackPicService, onCreate()");
        slientCamera = new SlientCamera(AppConst.getApplication());
        if (slientCamera.openCamere()) {
            return true;
        }
        slientCamera = null;
        return false;
    }

    @Override
    public synchronized boolean isOpen() {
        return slientCamera != null;
    }

    @Override
    public synchronized int tackPicture( RunnablePR<byte[],Void> bc) {
        if (slientCamera != null)

            return slientCamera.tackPicture(bc)==false?2:0;

        return 1;
    }

    @Override
    public synchronized void close() {
        Log.i(TAG, "SlientTackPicService, onDestroy()");
        if(slientCamera!=null)
        slientCamera.closeCamera();
        slientCamera = null;
    }


}
